package com.patterns.proxy.commonProxy;

/**
 * Created by Xiao Yiyun on 2017/4/22.
 * 代理类
 */
public class Proxy implements Subject {
    //确定要代理的实现类
    private  Subject subject = null;
    //默认被代理玩家
    public Proxy() {
        this.subject = new RealSubject();
    }
    //通过构造函数传递代理者
    public Proxy(Subject subject) {
        this.subject = subject;
    }
    //预处理
    private void before() {
        System.out.println("before method");
    }
    //善后处理
    private  void after() {
        System.out.println("after method");
    }
    public void method() {
        this.subject.method();
    }
}
